package com.deepblue.image.maker.handler;

import com.spotify.docker.client.ProgressHandler;
import com.spotify.docker.client.exceptions.DockerException;
import com.spotify.docker.client.messages.ProgressMessage;
import lombok.extern.slf4j.Slf4j;

/**
 * 日志打印处理器
 *
 * @author yymagicer
 * @version 1.0
 * @date 2021/11/10 上午11:11
 */
@Slf4j
public abstract class AbstractLoggingPrintHandler implements ProgressHandler {


     String sendUser;

    /**
     * 发送日志
     */
    abstract void sendLog(ProgressMessage message,String sendUser) throws DockerException ;


    @Override
    public void progress(ProgressMessage message) throws DockerException {
        if (message.error() != null) {
            throw new DockerException(message.toString());
        }
        log.info("build: {}", message);
        sendLog(message,sendUser);
    }
}
